//
//  ICTitleLoadingView.m
//  ICome
//
//  Created by zhangrongwu on 16/7/19.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICTitleLoadingView.h"
#import "ICHeaderFile.h"

@implementation ICTitleLoadingView

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    }
    return self;
}
-(void)layoutSubviews {
    [super layoutSubviews];
    [self layoutSubview];

}

-(void)layoutSubview {
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY);
    }];
   
    [self.activityIndicator mas_remakeConstraints:^(MASConstraintMaker *make) {
       make.right.equalTo(self.titleLabel.mas_left).offset(-5);
       make.centerY.equalTo(self.mas_centerY);
   }];
}

-(void)startLoading {
//    self.activityIndicator.hidden = NO;
//    self.activityIndicator.alpha = 1;
    [self.activityIndicator startAnimating];
}
-(void)endLoading {
//    self.activityIndicator.hidden = YES;
//    self.activityIndicator.alpha = 0;
    [self.activityIndicator stopAnimating];
}

-(UIActivityIndicatorView *)activityIndicator {
    if (!_activityIndicator) {
        _activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
        _activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
        [self addSubview:_activityIndicator];
        _activityIndicator.hidden = YES;
    }
    return _activityIndicator;
}

-(UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = ICBOLDFont(18);//状态栏title
        _titleLabel.textColor = DEFAULT_SUBJECT_COLOR;
        [self addSubview:_titleLabel];
    }
    return _titleLabel;
}

@end
